

export default{
	namespaced: true,
	
	state: () => ({
		//address.userName
		//address.postalCode
		//address.provinceName
		//address.cityName
		//address.countyName
		//address.detailInfo
		//address.nationalCode
		//address.telNumber
		address:JSON.parse(uni.getStorageSync('address') || '{}'),
		token:uni.getStorageSync('token') || '',
		userInfo:JSON.parse(uni.getStorageSync('userInfo') || '{}')
	}),
	mutations:{
		updateAddress(state,address){
			state.address = address
			this.commit('user/saveAddressToStorage')
		},
		saveAddressToStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		saveTokenToStorage(state){
			uni.setStorageSync('token',JSON.stringify(state.token))
		},
		saveUserInfoToStorage(state){
			uni.setStorageSync('userInfo',JSON.stringify(state.userInfo))
		},
		updateToken(state,token){
			state.token = token
			this.commit('user/saveTokenToStorage')
		},
		updateUserInfo(state,userInfo){
			state.userInfo = userInfo
			this.commit('user/saveUserInfoToStorage')
		}
	},
	actions:{

	},
	getters: {
		addr(state){
			return state.address.provinceName+state.address.cityName+state.address.countyName+state.address.detailInfo 
		}
	},
	modules: {}
}
